package cn.com.guage.dtm.metadata.service.impl;

import java.util.Arrays;
import java.util.List;
import cn.com.guage.dtm.common.utils.DateUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.guage.dtm.metadata.mapper.MdFieldMapper;
import cn.com.guage.dtm.metadata.domain.MdField;
import cn.com.guage.dtm.metadata.service.IMdFieldService;
import cn.com.guage.dtm.common.core.text.Convert;

/**
 * 字段MD定义Service业务层处理
 * 
 * @author liujun
 * @date 2021-06-24
 */
@Service
public class MdFieldServiceImpl implements IMdFieldService 
{
	private static final Logger log = LoggerFactory.getLogger(MdFieldServiceImpl.class);
    @Autowired
    private MdFieldMapper mdFieldMapper;

    /**
     * 查询字段MD定义
     * 
     * @param fieldId 字段MD定义ID
     * @return 字段MD定义
     */
    @Override
    public MdField selectMdFieldById(Long fieldId)
    {
        return mdFieldMapper.selectMdFieldById(fieldId);
    }

    /**
     * 查询字段MD定义列表
     * 
     * @param mdField 字段MD定义
     * @return 字段MD定义
     */
    @Override
    public List<MdField> selectMdFieldList(MdField mdField)
    {
        return mdFieldMapper.selectMdFieldList(mdField);
    }

    /**
     * 新增字段MD定义
     * 
     * @param mdField 字段MD定义
     * @return 结果
     */
    @Override
    public int insertMdField(MdField mdField)
    {
        mdField.setCreateTime(DateUtils.getNowDate());
        return mdFieldMapper.insertMdField(mdField);
    }

    /**
     * 修改字段MD定义
     * 
     * @param mdField 字段MD定义
     * @return 结果
     */
    @Override
    public int updateMdField(MdField mdField)
    {
        mdField.setUpdateTime(DateUtils.getNowDate());
        return mdFieldMapper.updateMdField(mdField);
    }

    /**
     * 删除字段MD定义对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMdFieldByIds(String ids)
    {
        return mdFieldMapper.deleteMdFieldByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除字段MD定义信息
     * 
     * @param fieldId 字段MD定义ID
     * @return 结果
     */
    @Override
    public int deleteMdFieldById(Long fieldId)
    {
        return mdFieldMapper.deleteMdFieldById(fieldId);
    }
    
    @Override
    public int deleteMdFieldByTableIds(String ids)
    {
    	log.debug("delete tableIds:",ids);
        return mdFieldMapper.deleteMdFieldByTableIds(Convert.toStrArray(ids));
    }
}
